<template>
	<view class="content">
		<view class="left">
			<view class="button">
				<img src="../../static/img/jifen.png" alt="">
				<span>积分余额</span>
			</view>
			<view class="jifen-number">
				<span class="number">{{ jifenData }}</span>
				<span class="text">积分</span>
			</view>
			<view class="time">有效期至2025年1月1日</view>
		</view>
		<view class="right">
			<!-- <view class="btns">积分充值&gt;</view> -->
			<view class="btns" @click="seeDetail()">积分明细 <span class="more">&gt;</span></view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				jifenData: 0,
			}
		},
		onShow() {
			this.getPointsList();
		},
		methods: {
			// 查看积分明细
			seeDetail() {
				uni.navigateTo({
					url: '/pages/integral/list'
				})
			},
			// 获取积分
			getPointsList() {
				let data = {
					customerId: uni.getStorageSync('openId').userId
				}
				this.$http({
					url: this.$myApi.pointsList + '?userId=' + data.customerId,
					method: 'GET',
					hideLoading: true,
					// data: data,
					success: res => {
						if (res.code == 200) {
							this.jifenData = parseFloat(res.rows[0].ctPoints).toFixed(2);  // 积分按元算
							// this.jifenData = 0;
						} else { }
					},
					fail: err => {
						
					},
					complete: e => {
						// uni.stopPullDownRefresh();
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #EFEFEF;
	}
</style>
<style lang="scss" scoped>
	.content {
		width: 690rpx;
		height: 291rpx;
		background: #FFFFFF;
		border-radius: 0px 0px 10px 10px;
		opacity: 1;
		margin: 0 auto;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		padding: 32rpx 42rpx 42rpx 42rpx;
		.right {
			.btns {
				background-color: rgba(0,185,82, 0.28);
				width: 160rpx;
				height: 50rpx;
				line-height: 50rpx;
				border-radius: 25rpx;
				font-size: 22rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				color: #0DBA5A;
				text-align: center;
				cursor: pointer;
				user-select: none;
				&:first-child {
					margin-top: 24rpx;
				}
				&:last-child {
					margin-top: 60rpx;
				}
				.more {
					margin-left: 6rpx;
					transform: scale(1, 1.5);
					display: inline-block;
					// margin-top: -4rpx;
					position: relative;
					top: -2rpx;
				}
			}
		}
		.left {
			.time {
				height: 30rpx;
				font-size: 22rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				color: #5F5F5F;
				line-height: 0px;
				// letter-spacing: 5rpx;
				// -webkit-background-clip: text;
				// -webkit-text-fill-color: transparent;
				margin-top: 42rpx;
			}
			.jifen-number {
				margin-top: 32rpx;
				height: 84rpx;
				line-height: 84rpx;
				.text {
					display: inline-block;
					font-size: 30rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					color: #2F2F2F;
					line-height: 0px;
					margin-left: 12rpx;
					line-height: 80rpx;
					position: relative;
					top: -4rpx;
				}
				.number {
					font-size: 60rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 800;
					color: #0DBA5A;
				}
			}
			.button {
				width: 160rpx;
				height: 50rpx;
				background: #0DBA5A;
				border-radius: 20rpx;
				opacity: 1;
				font-size: 22rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: bold;
				text-align: center;
				color: #FFFFFF;
				line-height: 50rpx;
				img {
					width: 30rpx;
					height: 30rpx;
					position: relative;
					top: 7rpx;
					left: -6rpx;
				}
			}
			
		}
	}
</style>